package client.domain.ui.global;

import client.internationalization.SandboxConstants;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.ui.PopupPanel;
import com.gwtext.client.widgets.ColorPalette;
import com.gwtext.client.widgets.form.Field;
import com.gwtext.client.widgets.event.ColorPaletteListenerAdapter;

/**
 * User: nbarrios
 * Date: Nov 19, 2009
 */
public class ColourPalettePopUp extends PopupPanel {

	//	Internationalization Strings
	private SandboxConstants constants = GWT.create(SandboxConstants.class);

	//  Attributes
	private final Field field;//The field where the colour will show be

	// Constructor
	/**
	 * Instantiate a new ColourPalettePopUp passing by argument the field where the colour will show be.
	 * @param parameterField
	 */
	public ColourPalettePopUp(Field parameterField) {
		super();
		this.field = parameterField;

		ColorPalette colorPalette = new ColorPalette();
		colorPalette.addListener(new ColorPaletteListenerAdapter() {
			public void onSelect(ColorPalette colorPalette, String color) {
				field.setStyle("background-color:" + color + ";background-image:none;");
				field.setValue(color);
				hide();
			}
		});


		this.add(colorPalette);
	}

}//  End Class
